<#include "/common/taglibs.ftl" />
<@menu code='${entityName!}'/>
<title><@spring.message code="${entityName!}" /> - <@spring.message code="list" /></title>
<div class="m-portlet m-portlet--mobile m-portlet--tabs">
    <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
            <div class="m-portlet__head-title">
                <h3 class="m-portlet__head-text">
                <@spring.message code="${entityName!}"/> ${RequestParameters['view']!}
                </h3>
            </div>
        </div>
        <div class="m-portlet__head-tools">
        <#include "/showcase/crud/sample/tabs.ftl" />
        </div>
    </div>
    <div class="m-portlet__body">
        <div class="table-container">
            <div class="table-actions-wrapper btn-group d-done">
                <button class="btn btn-sm btn-primary m-btn m-btn--icon"><i class="la la-plus"></i> <@spring.message code="button.add" /></button>
                <button class="btn btn-sm btn-info m-btn m-btn--icon"><i class="la la-edit"></i> <@spring.message code="button.edit" /></button>
                <button class="btn btn-sm btn-danger m-btn m-btn--icon"><i class="la la-remove"></i> <@spring.message code="button.delete" /></button>
                <button class="btn btn-sm btn-secondary m-btn m-btn--icon"><i class="la la-refresh"></i> <@spring.message code="button.refresh" /></button>
                <div class="btn-group" role="group">
                    <button type="button" class="btn btn-sm btn-secondary dropdown-toggle" data-toggle="dropdown">
                    <@spring.message code="button.more" />
                    </button>
                    <div class="dropdown-menu">
                        <a class="dropdown-item" href="#">Dropdown link</a>
                        <a class="dropdown-item" href="#">Dropdown link</a>
                        <a class="dropdown-item" href="#">Dropdown link</a>
                        <a class="dropdown-item" href="#">Dropdown link</a>
                    </div>
                </div>
            </div>
            <table class="table table-striped- table-bordered table-hover table-checkable" id="datatable"
            >
                <thead>
                    <tr role="row" class="heading">
                        <th width="1%" data-checkable="true" data-orderable="false"></th>
                        <th width="5%" data-data="id" data-searchable="false"> ID# </th>
                        <th width="5%" data-data="name"> <@spring.message code="sample.name"/> </th>
                        <th width="8%" data-data="gender" data-render="renderGender" data-search-type="<@searchTypeSelect items=genders/>"> <@spring.message code="sample.gender"/> </th>
                        <th data-data="email"> <@spring.message code="sample.email"/> </th>
                        <th width="8%" data-data="activated" data-render="renderBoolean" data-search-type="<@searchTypeSelectBoolean/>"> <@spring.message code="activated"/> </th>
                        <th width="5%" class="center" data-data="age" data-search-type="range" > <@spring.message code="sample.age"/> </th>
                        <th width="5%" class="center" data-data="salary" data-search-type="range" > <@spring.message code="sample.salary"/> </th>
                        <th width="10%" class="center" data-data="birthday" data-search-type="daterange" data-render="renderDate"> <@spring.message code="sample.birthday"/> </th>
                        <th width="15%" class="center" data-data="lastModifiedDate" data-search-type="daterange" data-render="renderDateTime"> <@spring.message code="lastModifyDate"/> </th>
                        <#--<th width="15%" data-actions="<@tableColumnButtons resourceIdentity='${resourceIdentity!}'/>"> <@spring.message code="action"/> </th>-->
                        <th width="15%" data-actions="111"> <@spring.message code="action"/> </th>
                    </tr>
                </thead>
                <tbody> </tbody>
            </table>
        </div>
    </div>
</div>

<page-plugin-style>
    <link href="${theme}/assets/vendors/custom/datatables/datatables.bundle.css" rel="stylesheet" type="text/css" />
</page-plugin-style>
<page-style>
</page-style>

<page-plugin-script>
    <script src="${theme}/assets/vendors/custom/datatables/datatables.bundle.js" type="text/javascript"></script>
    <script src="${static}/scripts/m.datatable.js" type="text/javascript"></script>
</page-plugin-script>
<page-script>
    <script>
        function renderGender( data, type, full, meta ){
            if(data=='male'){
                return '<@spring.message code="gender.male"/>';
            } else {
                return '<@spring.message code="gender.female"/>';
            }
        }

        var drawCallback = function(grid, $table){
            console.log('user table draw callback', grid, $table);
            if(grid.getDataTable().data().length==0) return;
        }

        jQuery(function($){
            $.m.datatable({
                src: "#datatable",
                dataTable: {
                    columnDefs: [
                        {
                            targets: -1,
                            title: 'Actions',
                            orderable: false,
                            render: function(data, type, full, meta) {
                                return '<span class="dropdown">\n    <a href="#" class="btn m-btn m-btn--hover-brand m-btn--icon m-btn--icon-only m-btn--pill" data-toggle="dropdown" aria-expanded="true">\n      <i class="la la-ellipsis-h"></i>\n    </a>\n    <div class="dropdown-menu dropdown-menu-right">\n        <a class="dropdown-item" href="#"><i class="la la-edit"></i> Edit Details</a>\n        <a class="dropdown-item" href="#"><i class="la la-leaf"></i> Update Status</a>\n        <a class="dropdown-item" href="#"><i class="la la-print"></i> Generate Report</a>\n    </div>\n</span>\n<a href="#" class="m-portlet__nav-link btn m-btn m-btn--hover-brand m-btn--icon m-btn--icon-only m-btn--pill" title="View">\n    <i class="la la-edit"></i>\n</a>';
                            },
                        }
                    ],
                }
            });
        });
    </script>
</page-script>